﻿using Md.Api.Entity.DapperModels.MdDB;

namespace Md.Dapper.Repositories.Md;
/// <summary>
/// 系统角色菜单关联仓储
/// </summary>
public class SysRoleMenuRep : BaseRep<SysRoleMenuModel>
{
    /// <summary>
    /// 通过角色编号获取(系统角色菜单关联)列表
    /// </summary>
    /// <param name="roleId">角色编号</param>
    /// <returns>IEnumerable<SysRoleMenuModel></returns>
    public IEnumerable<SysRoleMenuModel> GetSysRoleMenuListByRoleId(long roleId)
    {
        string sqlFields = " `id` ,`role_id` ,`menu_id` ";

        string sqlWhere = " and `role_id` = @RoleId ";

        return QueryList(sqlFields, sqlWhere, new { RoleId = roleId });
    }
    /// <summary>
    /// 通过角色编号删除(角色菜单关联)数据
    /// </summary>
    /// <param name="roleId">角色编号</param>
    /// <returns>int</returns>
    public int DeleteMenuByRoleId(long roleId)
    {
        string sqlWhere = " and `role_id` = @RoleId ";

        return Delete(sqlWhere, new { RoleId = roleId });
    }
}
